programming4us
           
 
 
Windows

SOA with .NET and Windows Azure : System.Transactions

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/6/2010 6:16:41 PM
.NET 1.0 and .NET 1.1 equated single resource transactions with ADO.NET and distributed resource transactions with .NET Enterprise Services. .NET 2.0 brought these two models together as the System.Transactions library, which established a simpler and more intuitive programming model with improved performance. (In fact, the System.Transactions library continues to be the framework for transactions in .NET 3.5 and .NET 4.0, as discussed in later chapters.)

Distributed Resource Transactions

A single resource transaction involved a single object and a single database, as shown in Figure 1. It was basically implemented in ADO.NET using an explicit programming model.

Figure 1. A single resource transaction involves only one object and one database.


A distributed resource transaction, on the other hand, may have had two or more objects that interacted with each other, along with two or more database resources (Figure 2).

Figure 2. A distributed resource transaction may involve multiple objects and multiple databases.


Prior to System.Transactions, the most common means of implementing DTCs was via .NET Enterprise Services (as discussed previously in this chapter). Specifically, the System.EnterpriseServices namespace was used.

This had several disadvantages:

  • It forced a class to inherit from the ServicedComponent class, which then required the assembly to be signed and registered in the GAC. This practice was time-consuming and difficult to maintain, thereby raising the barrier to using transactions.

  • It forced the use of distributed DTCs, even when a single object or a single resource was involved. The overhead imposed a noticeable performance cost.

  • It required administering the component in COM+ services, which was cumbersome.

  • .NET Enterprise Services transactions were tightly coupled to COM+ design considerations, forcing applications to factor in just-in-time activation, object pooling, state-aware programming model, and so on.

System.Transactions was introduced to alleviate these problems and to provide a simpler programming interface.

Some of its features included the following:

  • It supported both single-resource transactions and distributed resource transactions and was incorporated directly into the CLR.

  • The System.Transactions namespace supported any resource manager that could speak either OLE transactions or the broadly adopted WS-AtomicTransaction protocol.

  • It contained classes that allowed you to write your own transactional application and resource manager and create and participate in a transaction with one or more participants.

  • The System.Transactions infrastructure supported transactions initiated in SQL Server, ADO.NET, MSMQ, and the MSDTC.

Explicit and Implicit Programming Models

System.Transactions included both explicit and implicit programming models. The explicit programming model was implemented using the Transaction class and the implicit programming model was based on the TransactionScope class.

The Transaction class was used to pass the transaction to the System.Data class or the database. The TransactionScope class was used to scope a code section into a transaction, as shown here:

Example 1.
using System;
using System.Transactions;
class Program
{
static void Main(string[] args)
{
using (TransactionScope ts = new TransactionScope())
{
ts.Complete();
}
}
}

In this example, calling the Complete() method results in the transaction being committed. If an exception was thrown inside the using construct, the TransactionScopeComplete() method was called (resulting in the transaction being rolled back). would be disposed before the

Ambient Transactions

System.Transactions further introduced the concept of “ambient” transactions. An ambient transaction was a transaction executed by code. Ambient transactions could be referenced using the Current property of the Transaction class. Transaction.Current flowed around with the code and was referenced as follows:

Example 2.
Transaction ambientTransaction = Transaction.Current();



Summary of Key Points

  • System.Transactions provided a platform for implementing distributed resource transactions by separating the application programming from the transaction management.

  • Although considered a legacy .NET technology, WCF continues to rely on System.Transactions as a foundation for transaction management.


Note

The Web services industry standards referenced in the next section and throughout subsequent chapters in this book can be accessed via www.soaspecs.com.

The industry standards collectively supported by ASMX and WSE are:

  • SOAP

  • WSDL

  • WS-Policy

  • WS-PolicyAttachments

  • WS-Addressing

  • WS-Security

  • WS-ReliableMessaging

  • WS-MetadataExchange


Other -----------------
- Windows 7 : Understanding Batch File Basics (part 2) - Using Batch File Parameters
- Windows 7 : Understanding Batch File Basics (part 1) - Creating Batch Files
- Discovering the Microsoft Azure Platform
- SOA with .NET and Windows Azure : Microsoft Messaging Queue (MSMQ)
- Windows 7 : Working at the Command Line (part 3)
- Windows 7 : Working at the Command Line (part 2)
- Windows 7 : Working at the Command Line (part 1)
- Windows 7 : Getting to the Command Line (part 2) - Running CMD
- Windows 7 : Getting to the Command Line (part 1)
- Windows Azure : Programming Access Control Service (part 10) - Deploying the Web Service in Windows Azure
- Windows Azure : Programming Access Control Service (part 9) - Configuring a Web Service Client to Acquire and Send SAML Tokens
- Windows Azure : Programming Access Control Service (part 8)
- Windows Azure : Programming Access Control Service (part 7) - Integrating ACS with a SAML Token Provider
- Windows Azure : Programming Access Control Service (part 6)
- Windows Azure : Programming Access Control Service (part 5)
- Windows Azure : Programming Access Control Service (part 4)
- Windows Azure : Programming Access Control Service (part 3)
- Windows Azure : Programming Access Control Service (part 2)
- Windows Azure : Programming Access Control Service (part 1)
- Windows 7 : Working with Registry Entries (part 3)
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us